
#@list()
#define main()

<script type="text/javascript">

	function setGridHeight(){
		var winHeight = $("body").height();
		$("#_BLOG_LIST").jqGrid('setGridHeight', winHeight-170);
	}

	function refresh(){
		sortListViewResult();
	}

	function sortListViewResult(index,sortorder){

		$("#_BLOG_LIST").jqGrid('setGridParam',{
			postData: {
				'orderName':index,
				'orderType':sortorder,
				'f_it_title':$('#queryUserName').val()
			}
		}).trigger('reloadGrid');
	}

	function add(){
		var index = layer.open({
			type: 2,
			title:'新增',
			area: ['90%', '70%'],
			maxmin:true,
			shadeClose: true, //点击遮罩关闭

			content:  '/blog/add'
		});

		this.layerIndex = index;
	}

	function edit(id){
		var index = layer.open({
			type: 2,
			title:'编辑',
			area: ['90%', '70%'],
			maxmin:true,
			shadeClose: true, //点击遮罩关闭

			content:  '/blog/edit?id='+id
		});

		this.layerIndex = index;
//		location.href="#(ctx)/blog/edit?id="+id;
	}

	function modify(){
		var rowid = $("#_BLOG_LIST").getGridParam('selarrrow');

		if(rowid.length == 1){
			edit(rowid.toString());
		}

		if(rowid.length == 0){
			msgbox("请选择要编辑的记录", "warn");
		}
	}


	function del(){
		var id = $("#_BLOG_LIST").getGridParam("selarrrow");
		var ids = new Array()
		for(j in id) {
			var rowData = $("#_BLOG_LIST").jqGrid("getRowData",id[j]);//根据上面的id获得本行的所有数据
			var rowid= rowData.f_it_id; //获得制定列的值 （auditStatus 为colModel的name）
			ids.push(rowid)
		}
		if(rowid.length !=0){
			layer.confirm('确定要删除选中的记录吗？', {
				btn: ['确定', '取消'], //可以无限个按钮
				btn1: function(index, layero){
					$.get("#(ctx)/blog/remove", {
						"ids": ids.toString()

					}, function(ret) {
						if(ret.state == "ok") {
							msgbox(ret.msg, "ok");
							refresh();
						}
					}, "json");
				}

			});

		}

		if(rowid.length ==0){
			msgbox("请选择要删除的记录", "warn");
		}
	}

</script>

<div class="ibox ">
	<div class="ibox-title" style="border:0px;">
		<form class="form-inline">
			<input type="text" class="form-control" id="queryUserName" placeholder="">
			<button class="btn btn-warning" type="button" onclick="sortListViewResult()"><i class="fa fa-search"></i> 查询</button>
			<button class="btn btn-success" type="button" onclick="add()"><i class="fa fa-plus"></i> 新增</button>

			<button class="btn btn-info" type="button" onclick="modify()"><i class="fa fa-paste"></i> 编辑</button>

			<button class="btn btn-danger" type="button" onclick="del()"><i class="fa fa-remove"></i> 删除</button>
		</form>
	</div>
	<div class="ibox-content">
		#(script)
	</div>
</div>
#end
